﻿@using Zj.CourseManage.DTO.Common
@using Zj.CourseManage.DTO.Common.Pagination
@model PaginatedList<OfficeDTO>
@{
    ViewData["Title"] = "科室列表";
}
<h2>@ViewData["Title"]</h2>
<hr />
<a asp-action="Create" class="text-success">添加科室</a>
<hr />
<form class="form-inline" role="form" method="get" asp-action="Index">
    <div class="form-group">
        <label class="sr-only" for="name">@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)</label>
        <input type="text" class="form-control" id="name" name="name" placeholder="@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)" value="@ViewData["searString"]">
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
    <a asp-action="Index">显示全部</a>
</form>
<hr />
<table class="table table-bordered table-condensed table-striped table-bordered-table-responsive">
    <tr>
        <th>
            <a asp-route-sortField="@ViewData["sortId"]" asp-route-searString="@ViewData["searString"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().Id)</a>
        </th>
        <th>
            <a asp-route-sortField="@ViewData["sortName"]" asp-route-searString="@ViewData["searString"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)</a>
        </th>
        <th>操作</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>@Html.DisplayFor(x => item.Id)</td>
            <td>@Html.DisplayFor(x => item.Name)</td>
            <th>
                @*<a asp-action="Delete" asp-route-id="@Html.DisplayFor(x => item.Id)" class="text-danger">删除</a>*@
                @*<button type="button" class="btn btn-default">Left</button>*@
                @*<button type="button" class="btn btn-danger btn_edit"  data-id="@item.Id">修改</button>*@
                <a asp-action="Edit" asp-route-id="@item.Id" class="text-primary">修改</a>
                <a asp-action="Delete" asp-route-id="@item.Id" class="text-danger">删除</a>
            </th>
        </tr>
    }
</table>
@{
    var previousDisable = Model.HasPrevious ? "" : "disabled";
    var nextDisable = Model.HasNext ? "" : "disabled";
    var previous = (int)ViewData["pageIndex"] - 1;
    var next = (int)ViewData["pageIndex"] + 1;
}
<nav aria-label="...">
    <ul class="pager">
        <li><a asp-action="Index" asp-route-searString="@ViewData["searString"]" asp-route-pageIndex="@previous" class="btn @previousDisable">Previous</a></li>
        <li><a asp-action="Index" asp-route-searString="@ViewData["searString"]" asp-route-pageIndex="@next" class="btn @nextDisable">Next</a></li>
    </ul>
</nav>

@section Scripts{
    <script type="text/javascript">
        //修改
        $(".btn_edit").click(function () {
            var me = $(this);
            var id = me.attr("data-id");
            $("#edit-modal").modal({
                remote: "/Offices/ModalEdit" + "/" + id + "?m=" + Math.random(),
                backdrop: 'static'
            });
            return false;
        });
    </script>
}


